<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>102_函数封装</title>
		<script>
			const arr = [1, 3, 3, 4, 3, 1, 9, 10, 8]
			const temp = arr.slice()
			temp[0] = 109;

			function sort(arr) {
				const tempArr = [...arr]
				for (let i = 0; i < arr.length; i++) {}
				return tempArr;
			}

			let ret = sort(arr)
			//console.log("原始数组", temp);
			//console.log("排序后数组", arr);

			class Person {
				constructor(name, age) {
					this.name = name;
					this.age = age;
				}
			}
			const personArr = [new Person("孙悟空", 9), new Person("猪八戒", 20), new Person("唐僧", 10)];

			function filler(arr) {
				const tempArr = []
				for (let i = 0; i < arr.length; i++) {
					if (arr[i].age < 18) {
						tempArr.push(arr[i])
					}
				}
				return tempArr;
			}

			ret = filler(personArr);
			console.log("年龄小于18的是", ret);


		</script>
	</head>
	<body>
	</body>
</html>